<?php
	include 'database.php';
	$trafo=isset($_REQUEST['id_trafo']) ? $_REQUEST['id_trafo'] : '';
	$link = pg_connect("user=".DB_USER." port=".DB_PORT." dbname=".DB_NAME." host=".DB_HOST." password=".DB_PASS);
	
	try
	{
		$sql = "SELECT * FROM hsig.v_medicion_datos where id_trafo = ".$trafo;
		
		$result = pg_exec($link, $sql);
		
		$arr = array();
		If (!$result) {
			pg_close($link);
			Echo '{success:false}';
		}else{
		while($obj = pg_fetch_object($result)){
			$arr[] = $obj;
		}
			pg_close($link);
			//Echo '{success:true,rows:'.json_encode($arr).'}';
			Echo '{success:true,data:'.json_encode($arr).'}';
		}
	}catch(Exception $e)
	{
		pg_close($link);
		echo '{success:false}';
	}
?>




		